1. Field of the Invention
The present invention relates to a method of writing/reading data to/from a flash memory in blocks and, and more particularly, to a method of driving logical address-to-physical address remapping when reading/writing data from/to a flash memory having a restriction on the number of partial write cycles, and a flash memory architecture suitable therefor.
2. Description of the Related Art
Like other storage devices such as conventional random access memories (RAMs), non-volatile storage devices and magnetic disks, flash memories can arbitrarily access data that are stored at specific positions. The principle difference is how data can be rewritten and erased. That is, if data is to be rewritten or erased after having been written to a block of a flash memory, which is partitioned into blocks of a predetermined size for block-based access, a unit containing the block must be rewritten or erased. A block in a flash memory is composed of bytes having contiguous physical addresses. This block is a basic unit of a flash memory. A unit is composed of a plurality of blocks and is a basic unit for which data can be physically erased and rewritten at a time.
Due to the rewrite or erase characteristics of the flash memory, as the number of erase cycles increases, write and update efficiency of data is degraded. Furthermore, when performing a rewrite/erase operation on the flash memory, data may be damaged by a failure. To prevent damage to data, a block (or sector) remapping technique has been employed.
This remapping technique manages mapping information between a logical block number (abbreviated as xe2x80x9cLBNxe2x80x9d) and a physical block number (abbreviated as xe2x80x9cPBNxe2x80x9d) for data written to a flash memory so that, when rewriting or erasing the corresponding data, the data may be accessed with the same LBN even if the PBN of the data is changed.
According to conventional remapping techniques, if data is to be rewritten, first, a unit containing the PBN of the data on a flash memory is searched for a physical block, to which data is not written, and then the data is written to the physical block. Mapping information between LBN and PBN of the data is updated. Thus, a user can access the corresponding data using the same LBN even if the PBN of the data is changed. In this case, erasure is indicated on status information relating to the previous physical block for the data.
For example, when data is written to units having physical unit number (PUN) 1 and PUN2 on a flash memory as shown in FIG. 1, if the user desires to rewrite data written to a block whose LBN is xe2x80x983xe2x80x99, PUN 1 is changed as shown in FIG. 2. That is, referring to an LBN-to-logical unit number (LUN) mapping table, LBN xe2x80x983xe2x80x99 corresponds to LUN xe2x80x982xe2x80x99. Then, referring to a LUN-to-PUN mapping table, LUN xe2x80x982xe2x80x99 corresponds to PUN xe2x80x981xe2x80x99. Thus, PUN 1, which is a unit whose PUN is xe2x80x9c1xe2x80x9d, is searched for an empty physical block. As seen from FIG. 1, physical block # 4 (PBN 4) is found as the empty one. The data relative to LBN xe2x80x983xe2x80x99 is written to the PBN 4, and then mapping information of a block allocation map (BAM) for PUN 1 is updated. Then, erasure is indicated as status information about PBN 1 in the BAM for PUN 1. However, in this case, as the number of unused physical blocks in a physical unit increases, the utilization efficiency of a flash memory decreases.
To solve this problem, according to conventional remapping techniques, as shown in FIG. 3, first, only used blocks in PUN1 are transferred to another unit PUN 2. Then, the corresponding PUN is converted to the PUN of the other unit, that is, from PUN1 to PUN2. As a result, even if data is transferred to the other unit, the data can be accessed using the same LUN.
This conventional remapping technique does not permit an actual erase operation, as long as an empty block or an empty unit exists in a unit or the flash memory, respectively. However, since an increased number of erased blocks increases the unusable area in the flash memory, a method of reusing portions where erased blocks exist may be required.
Furthermore, in the event of a system failure such as power cut-off during a write operation or unit reuse operation, user data or data used for remapping may be damaged. Thus, to protect data from such a failure, a conventional method involves writing status information to a corresponding block or unit and appropriately modifying the written status information during an operation, thereby performing a recovery operation.
As described above, the conventional remapping technique involves performing a partial write operation numerous times in order to store and manage mapping information as well as data. Thus, it is difficult to apply the conventional remapping technique to a flash memory such as a NAND-type flash memory as it is. This is because the number of partial write cycles or the number of program cycles within the same page is limited to five or three in the case of a NAND-type flash memory. Thus, information written to a block or unit cannot be revised many times. For example, in the event of a system failure, a recovery operation may not be normally performed because the amount of revision of status information written to a corresponding block or unit is limited as described above.
Furthermore, in order to indicate the status of a predetermined block in a process such as free (FF)xe2x86x92allocated (8F)xe2x86x92being written (4F)xe2x86x92written (2F)xe2x86x92being erasing (0F)xe2x86x92erased (00), or to indicate the status of a predetermined unit in a process such as free (FF)xe2x86x92being copied (8F)xe2x86x92valid (4F)xe2x86x92being transferred (2F), a write operation is performed on the same physical position at least three or five times. In addition, considering that a path of user data or error correction code (ECC) is written to a unit or a block, it is difficult to apply the conventional remapping to a flash memory in which the number of partial write cycles is limited to three or five.
To solve the above problems, it is an objective of the present invention to provide a method of driving remapping in a flash memory, by which the status of a block and a unit can be written and handled while keeping the number of partial write cycles to a minimum, and a flash memory architecture adapted thereto.
It is another objective of the present invention to provide a method of driving remapping in a flash memory that indicates status information relating to a block and a unit with a smaller number of partial write cycles using a wrap-count, and a flash memory architecture adapted thereto.
It is still another objective of the present invention to provide a method of driving remapping suitable for a NAND-type flash memory, and a flash memory architecture adapted thereto.
Accordingly, to achieve the above objectives, the present invention provides a method of driving remapping in a flash memory which is partitioned into a plurality of units, each unit having one or more blocks. The method includes searching for a predetermined physical unit based on mapping information about a predetermined block, searching the found physical unit for another block if the predetermined block exists in a valid state in the physical unit, the status of which is free, changing the status of the other block into a status next to the status of the predetermined block, writing new data and additional information such as a logical block number to the other block, and changing the status of the predetermined block into a deleted state.
Preferably, the method further includes, when the predetermined block does not exist or exists in a deleted state, setting the status of the predetermined block to free and searching for another block whose status is free and, when the other block does not exist, performing a reclaim operation on the physical unit.
Preferably, performing a reclaim operation includes determining a source unit to be reclaimed and a transfer unit, setting the statuses of the source unit and the transfer unit to being transferred and being copied, respectively, copying valid blocks and related meta information and header information within the source unit, setting the transfer unit, the status of which has been set as being copied, to a valid state, while increasing the number of erase cycles (wear level) of the source unit, and deleting the source unit while writing the number of erase cycles to the source unit.
According to the present invention, a flash memory is preferably constructed such that a first block of the unit is allocated so as to write information including a logical unit number, validity of a status, and the number of erase cycles for a previous block, a second block of the unit is allocated so as to write information including the status of copying/transferring and the number of erase cycles (wear level), and information indicating the status of a block determined based on a wrap-count is written at a predetermined area of a spare array in a block, to which data of the unit is written.